package com.wfm.niuke.doublepoint;
public class PEight8合并两个有序数组 {
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int p1 = m-1;
        int p2 = n-1;
        int tail = m+n-1;
        int cur = 0;
        while (p1!=-1||p2!=-1){
            if(p1==-1){
                cur=nums2[p2--];
            }else if(p2==-1){
                cur=nums1[p1--];
            }else if(nums1[p1]>nums2[p2]){
                cur=nums1[p1--];
            }else {
                cur = nums2[p2--];
            }
            nums1[tail--]=cur;
        }
    }
}
//leetcode submit region end(Prohibit modification and deletion)

    public static void main(String[] args) { 
        Solution solution = new PEight8合并两个有序数组().new Solution();
    }
}